package com.bj58.ecdata.calc.dbservice.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bj58.ecdata.calc.dbservice.dao.ClickDao;
import com.bj58.ecdata.calc.dbservice.dao.DisplayDao;
import com.bj58.ecdata.calc.dbservice.dao.InfoDao;
import com.bj58.ecdata.calc.dbservice.dao.ResumeAddDao;
import com.bj58.ecdata.calc.dbservice.dao.SearchWordDao;
import com.bj58.ecdata.calc.dbservice.dao.TrackDao;
import com.bj58.ecdata.calc.dbservice.dao.TrackDao_TMP;
import com.bj58.ecdata.calc.dbservice.dao.model.ClickModel;
import com.bj58.ecdata.calc.dbservice.dao.model.DisplayModel;
import com.bj58.ecdata.calc.dbservice.dao.model.InfoModel;
import com.bj58.ecdata.calc.dbservice.dao.model.ResumeAddModel;
import com.bj58.ecdata.calc.dbservice.dao.model.SearchWord;
import com.bj58.ecdata.calc.dbservice.dao.model.TrackModel;
import com.bj58.ecdata.calc.dbservice.dao.model.TrackModel_TMP;
import com.bj58.ecdata.calc.dbservice.service.DataOptService;

/**
 * @author lichao
 *
 */
@Service
public class DataOptServiceImpl implements DataOptService {

	@Autowired
	private TrackDao trackDao;
	@Autowired(required=false)
	private TrackDao_TMP trackDao_TMP;
	@Autowired
	private DisplayDao displayDao;
	@Autowired
	private ClickDao clickDao;
	@Autowired
	private SearchWordDao searchWordDao;
	@Autowired
	private InfoDao infoDao;
	@Autowired
	private ResumeAddDao resumeAddDao;

	@Override
	public void insertTrack(TrackModel model) {
//		if (model == null || model.getTime() == null || model.getPlatform() == null || model.getBussline() == null || model.getPv() == null
//				|| model.getListpv() == null || model.getVppv() == null || model.getUv() == null) {
//			throw new BusinessException("error params! " + model.toString());
//		}
		trackDao.save(model);
	}

	@Override
	public void insertDisplay(DisplayModel model) {
//		if (model == null || model.getTime() == null || model.getPlatform() == null || model.getBussline() == null || model.getPv() == null
//				|| model.getAd() == null || model.getAdNum() == null) {
//			throw new BusinessException("error params! " + model.toString());
//		}
		displayDao.save(model);
	}

	@Override
	public void insertClick(ClickModel model) {
//		if (model == null || model.getTime() == null || model.getPlatform() == null || model.getBussline() == null || model.getPv() == null
//				|| model.getCash() == null || model.getCost() == null || model.getCustNum() == null || model.getCity1Id() == null
//				|| model.getCityType() == null || StringUtils.isBlank(model.getCate2Name()) || StringUtils.isBlank(model.getCate2Id())
//				|| StringUtils.isBlank(model.getCity1Name())) {
//			throw new BusinessException("error params! " + model.toString());
//		}
		clickDao.save(model);
	}

	@Override
	public void insertSearchWord(SearchWord model) {
//		if (model == null || model.getTime() == null || model.getPlatform() == null || model.getBussline() == null || model.getSearchWord() == null
//				|| model.getCount() == null) {
//			throw new BusinessException("error params! " + model.toString());
//		}
		searchWordDao.save(model);
	}

	@Override
	public void insertInfo(InfoModel model) {
//		if (model == null || model.getTime() == null || model.getPlatform() == null || model.getBussline() == null || model.getInfoNum() == null) {
//			throw new BusinessException("error params! " + model.toString());
//		}
		infoDao.save(model);		
	}

	@Override
	public void insertResumeAdd(ResumeAddModel model) {
//		if (model == null || model.getTime() == null || model.getPlatform() == null || model.getAddNum() == null) {
//			throw new BusinessException("error params! " + model.toString());
//		}
		resumeAddDao.save(model);
	}

	@Override
	public void insertTrack_TMP(TrackModel_TMP model) {
//		if (model == null || model.getTime() == null || model.getPlatform() == null || model.getBusiLine() == null || model.getPv() == null
//				|| model.getListpv() == null || model.getVppv() == null ) {
//			throw new BusinessException("error params! " + model.toString());
//		}
		trackDao_TMP.save(model);
	}

}
